Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
Angular/general front-end - should components "open a dialog"?

Assuming MatDialog or any "dialog opening service" implementation, where a dialog is opened with dialogService.open, would the "dialog opening logic" be suited in the component itself, or in a Store library (NGRX) effect?

component.ts

foo(): void {
  this.dialogService.openDialog(BarDialog, params)
}

vs

component.ts

foo(): void {
  this.store.dispatchAction(OpenBarDialog, params)
}

and the Effect would have the "dialog opening logic". My intuition is that "opening a dialog is a side effect".

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I don’t think there is a specific single answer to this question, it all comes down to what you need. Here’s my two cent that I absolutely mean as a matter to discuss about (!)

Having this logic in an effect makes this a lot easier to refactor and reuse eventually. If the „answer“ to this dialog (reacting to eg close-action) however is only meant to be consumed by the component you started to open the dialog with, then why abstract everything into an effect in the first place?

On the other hand if you go all the way with NGRX you eventually end up with code that’s a lot more readable and reasonable.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda